home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOpus Plus
/
DOpus Plus.iso
/
Tutorial
/
ARexx Tutorial
/
TuteRexx
/
DirTree.dopus5
< prev
next >
Wrap
Text File
|
1998-10-07
|
3KB
|
121 lines
/*
$VER: DirTree.dopus5 0.2 (7.10.98)
Call as: ARexx DOpus5:ARexx/DirTree.dopus5 [REGEN] <Device>
Flags Run Async
where: REGEN = causes a new directory tree file to be created.
Device = the device, eg. HD0:, SD0:, DF0:, etc
Example: DirTree.dopus5 HD0:
*/
options results
parse arg regen device
if device = '' then device = regen
regen = regen ~= device
address 'DOPUS.1'
if ~show('l','rexxsupport.library') then
call addlib('rexxsupport.library',0,-30)
device = strip(strip(device,,'"'))
oldcd = pragma('d',device)
device = pragma('d',oldcd)
if right(device,1) ~= ':' then do
dopus request '"Specify DEVICE only, eg. ''HD0:''" OK'
exit
end
tfile = left(device,pos(':',device))||'.dirtree'
if regen then call delete(tfile)
if ~exists(tfile) then do
address command 'List 'device' DIRS ALL LFORMAT "%P%N" >T:dirtree.temp'
address command 'Sort T:dirtree.temp 'tfile
'command protect 'tfile' set H'
call delete('T:dirtree.temp')
end
if ~open('dirtree',tfile,'r') then do
dopus request '"ERROR: Unable to open ''tree'' file." OK'
exit
end
else do
totlines = 0
do while ~eof('dirtree')
call readln('dirtree')
totlines = totlines + 1
end
call seek('dirtree',0,'b')
nlength = length(totlines)
end
lister new invisible mode name
handle = result
lister set handle field off
lister set handle toolbar
lister set handle busy on
info.NAME = copies('0',nlength)
info.DISPLAY = device
lister addstem handle info.
lister refresh handle full
lister set handle value info.NAME device
lister set handle visible on
linenum = 1
do while ~eof('dirtree')
dirline = readln('dirtree')
path = dirline
if pos(':',dirline) ~= 0 then parse var dirline dev ':' dirline
if dirline ~= '' then do
linenum = linenum + 1
if pos('/',dirline) ~= 0 then do
howmany = 0
do while pos('/',dirline) ~= 0
parse var dirline fore'/'dirline
howmany = howmany + 1
end
dirline = copies(' ',3 * howmany)||dirline
end
dirline = ' '||dirline
do i = 1 to length(dirline) by 3
if substr(dirline,i + 3,1) ~= ' ' | substr(dirline,i + 4,1) ~= ' ' then do
dirline = overlay('+--',dirline,i)
leave
end
end
info.NAME = right(linenum,nlength,'0')
info.DISPLAY = dirline
lister addstem handle info.
lister refresh handle
lister set handle value info.NAME path
end
end
call close('dirtree')
lister set handle busy off
call openport('DirTree-handler')
lister set handle handler 'DirTree-handler'
do until event = 'inactive'
if waitpkt('DirTree-handler') then do
packet = getpkt('DirTree-handler')
if packet ~= '00000000'x then do
event = getarg(packet,0)
name = getarg(packet,2)
if event = 'doubleclick' then do
lister query handle value name
path = result
lister set handle handler
lister set handle toolbar toolbar
lister wait handle quick
lister read handle path force
end
call reply(packet,0)
end
end
call closeport('DirTree-handler')
exit